import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class 第二大整数 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        List<Integer> a = new ArrayList<Integer>();
        while (n!=0){
            a.add(n);
            n = scanner.nextInt();
        }
        Object[] b = a.toArray();
        Arrays.sort(b);
        System.out.println(b[b.length-2]);
    }
}
